const app = {
  state: {
    viewTabs: JSON.parse(localStorage.getItem('views')) || [
      {
        title: '桌面端',
        type: 'desktop',
        html: '',
        js: '',
        css: '',
        width: '',
        height: ''
      }
    ],
    IBaseInfo: JSON.parse(localStorage.getItem('IBaseInfo')) || {},
    schemaTreeData: JSON.parse(localStorage.getItem('schemaTreeData')) || [{
      el_id: 'form_0',
      controlName: '默认表单',
      isRepeat: false,
      group: []
    }]
  },
  mutations: {
    updateViewTabs(state, data) {
      state.viewTabs = data
      localStorage.setItem('views', JSON.stringify(data))
    },
    updateIBaseInfo(state, data) {
      state.IBaseInfo = data
      localStorage.setItem('IBaseInfo', JSON.stringify(data))
    },
    updateSchemaTreeData(state, data) {
      state.schemaTreeData = data
      localStorage.setItem('schemaTreeData', JSON.stringify(data))
    }
  }
}

export default app
